const Mock = require("mockjs");
const Random = Mock.Random;
const getComponentList = require("./getComponent");

function getStatList(len = 10) {
  let arr = [];
  const getComponent = getComponentList();

  for (let i = 0; i < len; i++) {
    const stat = {
      _id: Random.id(),
    };

    getComponent.forEach((item) => {
      switch (item.type) {
        case "questionInput":
          stat[item.fe_id] = Random.ctitle();
          break;
        case "questionRadio":
          stat[item.fe_id] = item.props.options[0].text;
          break;
        case "questionCheckbox":
          stat[item.fe_id] =
            item.props.options[0].text + "," + item.props.options[1].text;
          break;
        case "questionTextarea":
          stat[item.fe_id] = Random.ctitle();
          break;
        default:
          stat[item.fe_id] = "";
          break;
      }
    });

    arr.push(stat);
  }
  return arr;
}

module.exports = getStatList;
